home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / src / gdb-4.12 / include / elf / internal.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-03  |  7.3 KB  |  196 lines

  1. /* ELF support for BFD.
  2.    Copyright (C) 1991, 1992 Free Software Foundation, Inc.
  3.  
  4.    Written by Fred Fish @ Cygnus Support, from information published
  5.    in "UNIX System V Release 4, Programmers Guide: ANSI C and
  6.    Programming Support Tools".
  7.  
  8. This file is part of BFD, the Binary File Descriptor library.
  9.  
  10. This program is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation; either version 2 of the License, or
  13. (at your option) any later version.
  14.  
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. GNU General Public License for more details.
  19.  
  20. You should have received a copy of the GNU General Public License
  21. along with this program; if not, write to the Free Software
  22. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  23.  
  24.  
  25. /* This file is part of ELF support for BFD, and contains the portions
  26.    that describe how ELF is represented internally in the BFD library.
  27.    I.E. it describes the in-memory representation of ELF.  It requires
  28.    the elf-common.h file which contains the portions that are common to
  29.    both the internal and external representations. */
  30.    
  31. /* Types used by various structures, functions, etc. */
  32.  
  33. typedef unsigned long    Elf32_Addr;    /* Unsigned program address */
  34. typedef unsigned long    Elf32_Off;    /* Unsigned file offset */
  35. typedef      long    Elf32_Sword;    /* Signed large integer */
  36. typedef unsigned long    Elf32_Word;    /* Unsigned large integer */
  37. typedef unsigned short    Elf32_Half;    /* Unsigned medium integer */
  38. typedef unsigned char    Elf32_Char;    /* Unsigned tiny integer */
  39.  
  40. #ifdef HOST_64_BIT
  41. typedef unsigned HOST_64_BIT    Elf64_Addr;
  42. typedef unsigned HOST_64_BIT    Elf64_Off;
  43. typedef          HOST_64_BIT    Elf64_Sxword;
  44. typedef unsigned HOST_64_BIT    Elf64_Xword;
  45. #endif
  46. typedef          long        Elf64_Sword;
  47. typedef unsigned long        Elf64_Word;
  48. typedef unsigned short        Elf64_Half;
  49.  
  50. /* NOTE that these structures are not kept in the same order as they appear
  51.    in the object file.  In some cases they've been reordered for more optimal
  52.    packing under various circumstances.  */
  53.  
  54. /* ELF Header */
  55.  
  56. #define EI_NIDENT    16        /* Size of e_ident[] */
  57.  
  58. typedef struct elf_internal_ehdr {
  59.   unsigned char        e_ident[EI_NIDENT];    /* ELF "magic number" */
  60.   bfd_vma        e_entry;        /* Entry point virtual address */
  61.   bfd_signed_vma    e_phoff;        /* Program header table file offset */
  62.   bfd_signed_vma    e_shoff;        /* Section header table file offset */
  63.   unsigned long        e_version;        /* Identifies object file version */
  64.   unsigned long        e_flags;        /* Processor-specific flags */
  65.   unsigned short    e_type;            /* Identifies object file type */
  66.   unsigned short    e_machine;        /* Specifies required architecture */
  67.   unsigned short    e_ehsize;        /* ELF header size in bytes */
  68.   unsigned short    e_phentsize;        /* Program header table entry size */
  69.   unsigned short    e_phnum;        /* Program header table entry count */
  70.   unsigned short    e_shentsize;        /* Section header table entry size */
  71.   unsigned short    e_shnum;        /* Section header table entry count */
  72.   unsigned short    e_shstrndx;        /* Section header string table index */
  73. } Elf_Internal_Ehdr;
  74.  
  75. #define elf32_internal_ehdr elf_internal_ehdr
  76. #define Elf32_Internal_Ehdr Elf_Internal_Ehdr
  77. #define elf64_internal_ehdr elf_internal_ehdr
  78. #define Elf64_Internal_Ehdr Elf_Internal_Ehdr
  79.  
  80. /* Program header */
  81.  
  82. struct elf_internal_phdr {
  83.   unsigned long    p_type;            /* Identifies program segment type */
  84.   unsigned long    p_flags;        /* Segment flags */
  85.   bfd_vma    p_offset;        /* Segment file offset */
  86.   bfd_vma    p_vaddr;        /* Segment virtual address */
  87.   bfd_vma    p_paddr;        /* Segment physical address */
  88.   bfd_vma    p_filesz;        /* Segment size in file */
  89.   bfd_vma    p_memsz;        /* Segment size in memory */
  90.   bfd_vma    p_align;        /* Segment alignment, file & memory */
  91. };
  92.  
  93. typedef struct elf_internal_phdr Elf_Internal_Phdr;
  94. #define elf32_internal_phdr elf_internal_phdr
  95. #define Elf32_Internal_Phdr Elf_Internal_Phdr
  96. #define elf64_internal_phdr elf_internal_phdr
  97. #define Elf64_Internal_Phdr Elf_Internal_Phdr
  98.  
  99. /* Section header */
  100.  
  101. typedef struct elf_internal_shdr {
  102.   unsigned int    sh_name;        /* Section name, index in string tbl */
  103.   unsigned int    sh_type;        /* Type of section */
  104.   bfd_vma    sh_flags;        /* Miscellaneous section attributes */
  105.   bfd_vma    sh_addr;        /* Section virtual addr at execution */
  106.   bfd_size_type    sh_size;        /* Size of section in bytes */
  107.   bfd_size_type    sh_entsize;        /* Entry size if section holds table */
  108.   unsigned long    sh_link;        /* Index of another section */
  109.   unsigned long    sh_info;        /* Additional section information */
  110.   file_ptr    sh_offset;        /* Section file offset */
  111.   unsigned int    sh_addralign;        /* Section alignment */
  112.  
  113.   /* The internal rep also has some cached info associated with it. */
  114.   void        *rawdata;        /* null if unused... */
  115.   void        *contents;        /* null if unused... */
  116.   bfd_vma    size;            /* size of contents (0 if unused) */
  117. } Elf_Internal_Shdr;
  118.  
  119. #define elf32_internal_shdr elf_internal_shdr
  120. #define Elf32_Internal_Shdr Elf_Internal_Shdr
  121. #define elf64_internal_shdr elf_internal_shdr
  122. #define Elf64_Internal_Shdr Elf_Internal_Shdr
  123.  
  124. /* Symbol table entry */
  125.  
  126. struct elf_internal_sym {
  127.   bfd_vma    st_value;        /* Value of the symbol */
  128.   bfd_vma    st_size;        /* Associated symbol size */
  129.   unsigned long    st_name;        /* Symbol name, index in string tbl */
  130.   unsigned char    st_info;        /* Type and binding attributes */
  131.   unsigned char    st_other;        /* No defined meaning, 0 */
  132.   unsigned short st_shndx;        /* Associated section index */
  133. };
  134.  
  135. typedef struct elf_internal_sym Elf_Internal_Sym;
  136.  
  137. #define elf32_internal_sym elf_internal_sym
  138. #define elf64_internal_sym elf_internal_sym
  139. #define Elf32_Internal_Sym Elf_Internal_Sym
  140. #define Elf64_Internal_Sym Elf_Internal_Sym
  141.  
  142. /* Note segments */
  143.  
  144. typedef struct elf_internal_note {
  145.   unsigned long    namesz;            /* Size of entry's owner string */
  146.   unsigned long    descsz;            /* Size of the note descriptor */
  147.   unsigned long    type;            /* Interpretation of the descriptor */
  148.   char        name[1];        /* Start of the name+desc data */
  149. } Elf_Internal_Note;
  150. #define Elf32_Internal_Note    Elf_Internal_Note
  151. #define elf32_internal_note    elf_internal_note
  152.  
  153. /* Relocation Entries */
  154.  
  155. typedef struct elf_internal_rel {
  156.   bfd_vma    r_offset;    /* Location at which to apply the action */
  157.   /* This needs to support 64-bit values in elf64.  */
  158.   bfd_vma    r_info;        /* index and type of relocation */
  159. } Elf_Internal_Rel;
  160.  
  161. #define elf32_internal_rel elf_internal_rel
  162. #define Elf32_Internal_Rel Elf_Internal_Rel
  163. #define elf64_internal_rel elf_internal_rel
  164. #define Elf64_Internal_Rel Elf_Internal_Rel
  165.  
  166. typedef struct elf_internal_rela {
  167.   bfd_vma    r_offset;    /* Location at which to apply the action */
  168.   bfd_vma    r_info;        /* Index and Type of relocation */
  169.   bfd_signed_vma r_addend;    /* Constant addend used to compute value */
  170. } Elf_Internal_Rela;
  171.  
  172. #define elf32_internal_rela elf_internal_rela
  173. #define elf64_internal_rela elf_internal_rela
  174. #define Elf32_Internal_Rela Elf_Internal_Rela
  175. #define Elf64_Internal_Rela Elf_Internal_Rela
  176.  
  177. /* dynamic section structure */
  178.  
  179. typedef struct {
  180.   Elf32_Sword d_tag;        /* entry tag value */
  181.   union {
  182.     Elf32_Word    d_val;
  183.     Elf32_Addr    d_ptr;
  184.   } d_un;
  185. } Elf32_Internal_Dyn;
  186.  
  187. #ifdef HOST_64_BIT
  188. typedef struct {
  189.   Elf64_Xword d_tag;        /* entry tag value */
  190.   union {
  191.     Elf64_Xword    d_val;
  192.     Elf64_Addr    d_ptr;
  193.   } d_un;
  194. } Elf64_Internal_Dyn;
  195. #endif
  196.